package cn.org.cute.ebocy.pf.platformservices;

import java.util.HashMap;
import java.util.List;
import cn.org.cute.ebocy.config.*;
import cn.org.cute.ebocy.util.CuteStaticMethod;
import cn.org.cute.security.domain.PlatformUser;

/**
 * 平台基本信息的接口类
 * @author fujian fujian@ebocy.com
 * @since 2011-12-19
 * @version v1.0
 */

public class PlatformServicesImpl {
	private FacebookPlatformDoingImpl facebookPlatformDoing = null;
	private RenRenPlatformDoingImpl renRenPlatformDoing = null;
	
	public PlatformServicesImpl(){
		facebookPlatformDoing = new FacebookPlatformDoingImpl();
		renRenPlatformDoing = new RenRenPlatformDoingImpl();
	}
	/**
	 * 获得用户信息
	 * @param paramsMap 参数
	 * @return PlatformUser 平台用户对象
	 */
	public PlatformUser getUsersProfile(HashMap<String,String> paramsMap) {
		PlatformUser userProfile = null;
		String platformName = Config.getPfName();
		
		if(CuteStaticMethod.isRenRenApp(platformName)){
			userProfile = renRenPlatformDoing.getUsersProfile(paramsMap);
		} else if(CuteStaticMethod.isFacebookApp(platformName)){
			userProfile = facebookPlatformDoing.getUsersProfile(paramsMap);
		}
		return userProfile;
	}
	
	/**
	 * 获得用户信息
	 * @param paramsMap 参数
	 * @return PlatformUser 平台用户对象
	 */
	public List<PlatformUser> getUsersProfiles(HashMap<String,String> paramsMap) {
		String platformName = Config.getPfName();
		List<PlatformUser> list = null;
		if(CuteStaticMethod.isRenRenApp(platformName)){
			list = renRenPlatformDoing.getUsersProfiles(paramsMap);
		} else if(CuteStaticMethod.isFacebookApp(platformName)){
			list = facebookPlatformDoing.getUsersProfiles(paramsMap);
		}
		return list;
	}
	
	/**
	 * 获得当前登录用户平台ID
	 * @param paramsMap 参数
	 * @return String 平台ID
	 */
	public String getLoggedInUser(HashMap<String, String> paramsMap){
		String uid = "0";
		String platformName = Config.getPfName();
		if(CuteStaticMethod.isRenRenApp(platformName)){
			uid = renRenPlatformDoing.getLoggedInUser(paramsMap)+"";
		} else if(CuteStaticMethod.isFacebookApp(platformName)){
			uid = facebookPlatformDoing.getLoggedInUser(paramsMap);
		}
		return uid;
	}
	
	/**
	 * 获取玩同一个游戏或应用的朋友信息<br>
	 * @params ifHaveProperty ，是否需要取得好友的屬性，flase:只獲得好友的ID
	 * @return<br>
	 * 平台uid=platformUser.getPfId();<br>
     * 用户头像=platformUser.getPfMainurl();<br>
     * 平台用户姓名=platformUser.getPfName();<br>
     * 具体的请参考PlatformUser对象<br>
	 * @throws Exception<br>
	 */

	public List<PlatformUser> getAppFriendsInfo(HashMap<String,String> paramsMap){
		List<PlatformUser> list = null;
		String platformName = Config.getPfName();
		if(("0").equals(paramsMap.get(Param.ParamName.UID.getName()))){
			paramsMap.put(Param.ParamName.UID.getName(), this.getLoggedInUser(paramsMap));
		}
		
		if(CuteStaticMethod.isRenRenApp(platformName)){
			list = renRenPlatformDoing.getAppFriendsInfo(paramsMap);
		} else if(CuteStaticMethod.isFacebookApp(platformName)){
			list = facebookPlatformDoing.getAppFriendsInfo(paramsMap);
		}
		return list;
	}
	
	/**
	 * 获取所有的朋友<br>
	 * @return<br>
	 * 平台uid=platformUser.getPfId();<br>
     * 用户头像=platformUser.getPfMainurl();<br>
     * 平台用户姓名=platformUser.getPfName();<br>
     * 具体的请参考PlatformUser对象<br>
	 * @throws Exception<br>
	 */
	public List<PlatformUser> getFriendsInfo(HashMap<String,String> paramsMap){
		List<PlatformUser> list = null;
		String platformName =  Config.getPfName();
		
		if(CuteStaticMethod.isRenRenApp(platformName)){
			list = renRenPlatformDoing.getFriendsInfo(paramsMap);
		} else if(CuteStaticMethod.isFacebookApp(platformName)){
			list = facebookPlatformDoing.getFriendsInfo(paramsMap);
		}
		return list;
	}
	
	/**
	 *  判断用户是不是某个公共主页的粉丝
	 *  params.put("PF_ID",pf_id); //平台ID
	 *  params.put("PAGE_ID",page_id); //公共主页ID,默认为该app的主页可以不设置
	 *  params.put("TOKEN",session_key); //session_key
	 *  @param page_id 公共主页ID，不填写/0 默认为当前应用的公共主页
	 */
	public boolean page_isFans(HashMap<String,String> paramsMap){
		boolean isFan = false;
		String platformName =  Config.getPfName();
		
		if(("0").equals(paramsMap.get(Param.ParamName.UID.getName()))){
			paramsMap.put(Param.ParamName.UID.getName(), this.getLoggedInUser(paramsMap)+"");
		}
		
		if(CuteStaticMethod.isRenRenApp(platformName)){
			isFan = renRenPlatformDoing.page_isFans(paramsMap);
		} else if(CuteStaticMethod.isFacebookApp(platformName)){
			isFan = facebookPlatformDoing.page_isFans(paramsMap);
		}
		
		return isFan;	
	}
	
	/**
	 * 判断用户是否已经对应用授权
	 * @param paramsMap 参数
	 * @return boolean
	 */
	public boolean getIsAppUser(HashMap<String, String> paramsMap)
			throws Exception {
		boolean isAppUser = false;
		String platformName =  Config.getPfName();
		if(CuteStaticMethod.isRenRenApp(platformName)){
			isAppUser = renRenPlatformDoing.getIsAppUser(paramsMap);
		}
		
		return isAppUser;
	}
	
	/**
	 * 判断是否为当前用户好友
	 * @param paramsMap 参数
	 * @return boolean
	 */
	public boolean getIsFriend(HashMap<String, String> paramsMap)
			throws Exception {
		boolean isFriend = false;
		String platformName =  Config.getPfName();
		
	
		
		return isFriend;
	}
	
	/**
	 * 判断用户是否为vip
	 * @param paramsMap 参数
	 * @return boolean
	 */
	public String getIsVip(HashMap<String, String> paramsMap)
			throws Exception {
		String isFriend = "0,0,0";
		String platformName =  Config.getPfName();
	
		
		return isFriend;
	}
	
	/**
	 * 判断用户是否登陆
	 * @param paramsMap 参数
	 * @return boolean
	 */
	public boolean getIsLogin(HashMap<String, String> paramsMap)
			throws Exception {
		boolean isFriend = false;
		String platformName =  Config.getPfName();
		
		return isFriend;
	}
	
	/**
	 * 过滤敏感关键词
	 * @param paramsMap 参数
	 * @return boolean
	 */
	public String getFilterWord(HashMap<String, String> paramsMap)
			throws Exception {
		String content = null;
		String platformName =  Config.getPfName();

		
		return content;
	}
	
	/**
	 * 支付接口（QQ）
	 * @param paramsMap 参数
	 * @return boolean
	 */
	public String buyGoods(HashMap<String, String> paramsMap)
			throws Exception {
		String content = null;
		String platformName =  Config.getPfName();

		
		return content;
	}
}
